
/* Define to prevent recursive inclusion --------------------------------------*/
#ifndef _DEV_C8624_H_
#define _DEV_C8624_H_
#ifdef EN_I2C_C8624
/* Exported define ------------------------------------------------------------*/
#define C8624_BUF_SIZE 96
#define C8624_SEG_NUM 12

#define C8624_LUMI_FULL 0xFF
#define C8624_LUMI_HALF 0x7F
#define C8624_LUMI_OFF 0

#define C8624_MARQUEE_NUM 19

/* Command type define --------------------------------------------------------*/
/*
 * @brief  broadcast enable
 * @param  0 -> CS mode
 *         1 -> broadcast mode
 */
typedef enum
{
    C8624_CSMode = 0u,
    C8624_BroadcastMode = 1u
} c8624_em_cmd_broadcast_enable_t;
/*
 * @brief  chip address
 * @param  chip address -> B5 bits, 0\2
 */
typedef enum
{
    C8624_CsAddress0 = 0u,
    C8624_CsAddress2 = 2u,
} c8624_em_cmd_cs_address_t;

/*
 * @brief  command type
 * @param  command type -> low 4 bits
 */
typedef enum
{
    C8624_CmdCommand = 0x01,
    C8624_CmdData = 0x02,
    C8624_CmdAdressData = 0x03,
    C8624_CmdDataUpdate = 0x04,
    C8624_CmdSoftReset = 0x08,
    C8624_CmdSleep = 0x0E,
    C8624_CmdWakeUp = 0x0D,
    C8624_CmdGlobalReset = 0x0B,
    C8624_CmdDataBack = 0x07
} c8624_em_cmd_type_t;

/* Current command define -----------------------------------------------------*/
/*
 * @brief  current gain
 * @param  0~63 -> 6.375~30mA
 * @note   Iout = 0.375 * (17 + G)
 */
typedef enum
{
    C8624_mA_6_375 = 0,
    C8624_mA_6_75 = 1,
    C8624_mA_7_125 = 2,
    C8624_mA_7_5 = 3,
    C8624_mA_7_875 = 4,
    C8624_mA_8_25 = 5,
    C8624_mA_8_625 = 6,
    C8624_mA_9 = 7,
    C8624_mA_9_375 = 8,
    C8624_mA_9_75 = 9,
    C8624_mA_10_125 = 10,
    C8624_mA_10_5 = 11,
    C8624_mA_10_875 = 12,
    C8624_mA_11_25 = 13,
    C8624_mA_11_625 = 14,
    C8624_mA_12 = 15,
    C8624_mA_12_375 = 16,
    C8624_mA_12_75 = 17,
    C8624_mA_13_125 = 18,
    C8624_mA_13_5 = 19,
    C8624_mA_13_875 = 20,
    C8624_mA_14_25 = 21,
    C8624_mA_14_625 = 22,
    C8624_mA_15 = 23,
    C8624_mA_15_375 = 24,
    C8624_mA_15_75 = 25,
    C8624_mA_16_125 = 26,
    C8624_mA_16_5 = 27,
    C8624_mA_16_875 = 28,
    C8624_mA_17_25 = 29,
    C8624_mA_17_625 = 30,
    C8624_mA_18 = 31,
    C8624_mA_18_375 = 32,
    C8624_mA_18_75 = 33,
    C8624_mA_19_125 = 34,
    C8624_mA_19_5 = 35,
    C8624_mA_19_875 = 36,
    C8624_mA_20_25 = 37,
    C8624_mA_20_625 = 38,
    C8624_mA_21 = 39,
    C8624_mA_21_375 = 40,
    C8624_mA_21_75 = 41,
    C8624_mA_22_125 = 42,
    C8624_mA_22_5 = 43,
    C8624_mA_22_875 = 44,
    C8624_mA_23_25 = 45,
    C8624_mA_23_625 = 46,
    C8624_mA_24 = 47,
    C8624_mA_24_375 = 48,
    C8624_mA_24_75 = 49,
    C8624_mA_25_125 = 50,
    C8624_mA_25_5 = 51,
    C8624_mA_25_875 = 52,
    C8624_mA_26_25 = 53,
    C8624_mA_26_625 = 54,
    C8624_mA_27 = 55,
    C8624_mA_27_375 = 56,
    C8624_mA_27_75 = 57,
    C8624_mA_28_125 = 58,
    C8624_mA_28_5 = 59,
    C8624_mA_28_875 = 60,
    C8624_mA_29_25 = 61,
    C8624_mA_29_625 = 62,
    C8624_mA_30 = 63
} c8624_em_cmd_current_gain_t;

/* Control command define -----------------------------------------------------*/
/*
 * @brief  clock mode command
 * @param  0 -> internal clock
 *         1 -> external clock
 */
typedef enum
{
    C8624_InternalClock = 0u,
    C8624_ExternalClock = 1u
} c8624_em_cmd_clock_mode_t;

/*
 * @brief  com scan command
 * @param  0x00~0x0F -> com1~com16
 */
typedef enum
{
    C8624_Com1 = 0u,
    C8624_Com2 = 1u,
    C8624_Com3 = 2u,
    C8624_Com4 = 3u,
    C8624_Com5 = 4u,
    C8624_Com6 = 5u,
    C8624_Com7 = 6u,
    C8624_Com8 = 7u,
    C8624_Com9 = 8u,
    C8624_Com10 = 9u,
    C8624_Com11 = 10u,
    C8624_Com12 = 11u,
    C8624_Com13 = 12u,
    C8624_Com14 = 13u,
    C8624_Com15 = 14u,
    C8624_Com16 = 15u
} c8624_em_cmd_com_scan_t;

/*
 * @brief  work mode command
 * @param  0 -> normal work mode
 *         1 -> test work mode
 */
typedef enum
{
    C8624_NormalMode = 0u,
    C8624_TestMode = 1u
} c8624_em_cmd_work_mode_t;

/*
 * @brief  data update command
 * @param  0 -> data arbitrary update
 *         1 -> data automatic update
 */
typedef enum
{
    C8624_ArbitraryUpdate = 0u,
    C8624_AutomaticUpdate = 1u
} c8624_em_cmd_data_update_t;

/* Display command define -----------------------------------------------------*/
/*
 * @brief  125C over-temperature protection
 * @param  0 -> enable 125C OTP
 *         1 -> disable 125C OTP
 */
typedef enum
{
    C8624_Otp125Enable = 0u,
    C8624_Otp125Disable = 1u
} c8624_em_cmd_over_t125_protect_t;

/*
 * @brief  set PWM clock
 * @param  0x00 -> 1M
 *         0x01 -> 2M
 *         0x02 -> 4M
 *         0x03 -> 8M
 */
typedef enum
{
    C8624_Clock1M = 0u,
    C8624_Clock2M = 1u,
    C8624_Clock4M = 2u,
    C8624_Clock8M = 3u
} c8624_em_cmd_pwm_clock_t;

/*
 * @brief  display enable
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_DisplayDisable = 0u,
    C8624_DisplayEnable = 1u
} c8624_em_cmd_display_enable_t;

/*
 * @brief  eliminate the ghosting
 * @param  0 -> slight
 *         1 -> strong
 */
typedef enum
{
    C8624_Slight = 0u,
    C8624_Strong = 1u
} c8624_em_cmd_ghost_reduction_t;

/*
 * @brief  row break time
 * @param  0x00 -> 4 pwm cycle
 *         0x01 -> 8 pwm cycle
 *         0x02 -> 12 pwm cycle
 *         0x03 -> 16 pwm cycle
 */
typedef enum
{
    C8624_PwmCycle4 = 0u,
    C8624_PwmCycle8 = 1u,
    C8624_PwmCycle12 = 2u,
    C8624_PwmCycle16 = 3u
} c8624_em_cmd_row_break_time_t;

/* System command define ------------------------------------------------------*/
/*
 * @brief  sleep function
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_SleepDisable = 0u,
    C8624_SleepEnable = 1u
} c8624_em_cmd_sleep_function_t;

/*
 * @brief  auto sleep function
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_AutoSleepDisable = 0u,
    C8624_AutoSleepEnable = 1u
} c8624_em_cmd_auto_sleep_function_t;

/*
 * @brief  global reset function
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_GlobalDisable = 0u,
    C8624_GlobalEnable = 1u
} c8624_em_cmd_global_reset_t;

/*
 * @brief  soft reset function
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_SoftDisable = 0u,
    C8624_SoftEnable = 1u
} c8624_em_cmd_soft_reset_t;

/*
 * @brief  150C over-temperature protection
 * @param  0 -> enable 150C OTP
 *         1 -> disable 150C OTP
 */
typedef enum
{
    C8624_Otp150Enable = 0u,
    C8624_Otp150Disable = 1u
} c8624_em_cmd_over_t150_protect_t;

/*
 * @brief  power down reset function
 * @param  0 -> disable
 *         1 -> enable
 */
typedef enum
{
    C8624_PowerDisable = 0u,
    C8624_PowerEnable = 1u
} c8624_em_cmd_power_down_reset_t;

/* Private variables ----------------------------------------------------------*/
typedef struct
{
    c8624_em_cmd_broadcast_enable_t emcmdBroadcastEnable;
    c8624_em_cmd_cs_address_t emCsAddress;
    c8624_em_cmd_type_t emCmdType;
    c8624_em_cmd_com_scan_t emComScan;
    c8624_em_cmd_data_update_t emDataUpdata;
    c8624_em_cmd_work_mode_t emWorkMode;
    c8624_em_cmd_clock_mode_t emClockMode;
    c8624_em_cmd_pwm_clock_t emPwmClock;
    c8624_em_cmd_display_enable_t emDisplay;
    c8624_em_cmd_ghost_reduction_t emGhostReduction;
    c8624_em_cmd_row_break_time_t emRowBreakTime;
    c8624_em_cmd_over_t125_protect_t emOverT125Protect;
    c8624_em_cmd_current_gain_t emCurrentGain;
    c8624_em_cmd_sleep_function_t emSleepFunction;
    c8624_em_cmd_global_reset_t emGlobalReset;
    c8624_em_cmd_soft_reset_t emSoftReset;
    c8624_em_cmd_over_t150_protect_t emOverT150Protect;
    c8624_em_cmd_auto_sleep_function_t emAutoSleepFunction;
    c8624_em_cmd_power_down_reset_t emPowerDownReset;
} c8624_ty_cmd_config_t;

typedef struct
{
    unsigned char Current;
    unsigned char Mode;
    unsigned char Display;
    unsigned char Control;
} c8624_ty_cmd_setting_t;

/* Exported variables ---------------------------------------------------------*/
/* display variable */
extern Ram unsigned char C8624_DisplayBuf[C8624_BUF_SIZE];
/* config variable */
extern Ram c8624_ty_cmd_config_t c8624_tCmdConfig;
extern Ram c8624_ty_cmd_setting_t c8624_tCmdSetting;

/* Exported functions ---------------------------------------------------------*/
extern void Dev_C8624_Init(void);
extern void Dev_C8624_DisplayClearBuf(void);
extern void Dev_C8624_DisplayAll(unsigned char lumi);
extern void Dev_C8624_SendAddressData(unsigned char DataAddr, unsigned char Data);
extern void Dev_C8624_DisplayBufAutomatic(void);
extern void Dev_C8624_DisplayIntoSleep(void);
extern void Dev_C8624_DisplayWakeUp(void);
extern unsigned char Dev_C8624_DisplayBreathBuf(void);
extern unsigned char *Dev_C8624_DisplayMarqueeBuf(void);
extern void Dev_C8624_Scan(void);
#endif /* __C8624_H__ */
#endif